package net.esj.basic.dao.ann.component.column;

import net.esj.basic.dao.ann.component.table.AbstractTable;

public abstract class AbstractColumn {
	
	private AbstractTable table;

	private String columnName;
	
	private Class type;
	
	private Integer length;
	
	private Object defaultz;
	
	private boolean notNull;
	
	public AbstractColumn(String columnName, Class type) {
		super();
		this.columnName = columnName;
		this.type = type;
	}

	public AbstractColumn(String columnName, Class type, Integer length) {
		super();
		this.columnName = columnName;
		this.type = type;
		this.length = length;
	}

	public AbstractColumn(String columnName, Class type, Integer length,
			Object defaultz) {
		super();
		this.columnName = columnName;
		this.type = type;
		this.length = length;
		this.defaultz = defaultz;
	}

	public AbstractColumn(String columnName, Class type, Integer length,
			Object defaultz, boolean notNull) {
		super();
		this.columnName = columnName;
		this.type = type;
		this.length = length;
		this.defaultz = defaultz;
		this.notNull = notNull;
	}
	
	public String getJavaPropertyName(){
		String tmpname = columnName.toLowerCase();
		StringBuilder sb = new StringBuilder();
		int i=0;
		for(String str : tmpname.split("_")){
			if(i==0){
				sb.append(str);
			}else{
				for(int j=0;j<str.length();j++){
					if(j==0){
						char c = (char) (str.charAt(j)-32);
						sb.append(c);
					}else{
						sb.append(str.charAt(j));
					}
				}
			}
		}
		return sb.toString();
	}

	public String getColumnName() {
		return columnName;
	}

	public void setColumnName(String columnName) {
		this.columnName = columnName;
	}

	public Class getType() {
		return type;
	}

	public void setType(Class type) {
		this.type = type;
	}

	public Integer getLength() {
		return length;
	}

	public void setLength(Integer length) {
		this.length = length;
	}

	public Object getDefaultz() {
		return defaultz;
	}

	public void setDefaultz(Object defaultz) {
		this.defaultz = defaultz;
	}

	public boolean isNotNull() {
		return notNull;
	}

	public void setNotNull(boolean notNull) {
		this.notNull = notNull;
	}
	
	public AbstractTable getTable() {
		return table;
	}

	public void setTable(AbstractTable table) {
		this.table = table;
	}

	public static void main(String[] args){
		char a = 'i';
		System.out.println(Character.valueOf((char)(a-32)).toString());
	}
	
}
